package cn.woo5.test.securitytest.config;


import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class RestAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {

  @Override
  public void onAuthenticationSuccess(HttpServletRequest req, HttpServletResponse resp, Authentication auth)
      throws IOException, ServletException {

    // do something after auth success.
    
//    CurrentUser curr = (CurrentUser) auth.getPrincipal();
//    AdminVo userVo = new AdminVo((Admin) curr.getUser());
//    resp.getWriter().write(mapper.writeValueAsString(userVo));

    clearAuthenticationAttributes(req);
  }

}
